import avail.*; import org.jdom.*; import org.jdom.input.SAXBuilder; import org.jdom.output.XMLOutputter; /** * Basic JDOM Example * Outputs any local XML file specified on the command line * Performs XML Validation * Example usage: * java jdom2 document.xml */ public class jdom2 { // Download and Output XML File public void process (String fileName) { try { // Use SAXBuilder // turn XML validation on SAXBuilder builder = new SAXBuilder (true); Document doc = builder.build(new File(fileName)); // If we get here without any exceptions, // the document is both well-formed and valid System.out.println ("Document is well-formed"); System.out.println ("Document is valid"); } catch (JDOMException e) { System.out.println ("JDOM Exception: "+e.getMessage()); } } public static void main (String[] args) { System.out.println ("JDOM2 Example with Validation"); System.out.println ("Downloading file: "+args[0]); jdom2 app = new jdom2(); app.process(args[0]); } }